package cn.edu.nuc.onlinestore.network;


import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Set;

import cn.edu.nuc.onlinestore.frame.AdminName;
import cn.edu.nuc.onlinestore.model.Carts;
import cn.edu.nuc.onlinestore.model.Client;
import cn.edu.nuc.onlinestore.model.Goods;
import cn.edu.nuc.onlinestore.model.UserCart;
import cn.edu.nuc.onlinestore.vo.Result;
import demo.factor.Ifactor.IFactory;

public class TCPServer extends Thread {
	
	private ServerSocket server = null;
	public TCPServer(){
		
		try {
			server = new ServerSocket( 9999 );
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
	@Override
	public void run() {
		
		Socket client = null;
		
			while(true){
				try {
					//阻塞等待客户端连接
					client = server.accept();
					if(AdminName.lab!=null)
					{
						AdminName.lab.setText("在线人数"+AdminName.onlinenumber.size());
					}
					//启动线程
					new Thread(new SeverThread(client)).start();
					
					}catch(Exception e){
						e.printStackTrace();
					}

			}
			
	}
}
